package com.gdth.bank.presenter;

import java.util.List;

import com.gdth.bank.bean.FlashBean;
import com.gdth.bank.model.MainModel;
import com.gdth.bank.view.MainView;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/** 
 * @author  Arvin: 
 * @version 2016年5月25日 下午10:40:57 
 * 
 */
public class MainPresenter {
	private MainView mMainView;
	private MainModel mMainModel;
	
	public MainPresenter(MainView mMainView){
		this.mMainView = mMainView;
		
		mMainModel = new MainModel();
	}
	
	public void getFlashBeans(){
		mMainModel.getFlashBeans()
			.subscribeOn(Schedulers.io())
			.unsubscribeOn(Schedulers.io())
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(new Subscriber<List<FlashBean>>(){

				@Override
				public void onCompleted() {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void onError(Throwable arg0) {
					// TODO Auto-generated method stub
					mMainView.showMessage("获取flash失败");
				}

				@Override
				public void onNext(List<FlashBean> arg0) {
					// TODO Auto-generated method stub
					mMainView.updateFlash(arg0);
				}
				
			});
	}
}
